package alvarodelrosal.chat.client.chataction.local;

import alvarodelrosal.chat.client.chataction.infraestructuraremota.OnlineConversations;
import alvarodelrosal.chat.client.modelo.ChatUser;
import alvarodelrosal.chat.client.modelo.Conversation;
import alvarodelrosal.chat.client.modelo.Message;
import java.util.List;

public class ChatChat implements ChatLocalAction {

    @Override
    public String getName() {
        return "Chat";
    }

    @Override
    public void doAction(List<String> parameters) {
        Conversation conversation = OnlineConversations.getConversation(Integer.parseInt(parameters.get(0)));
        ChatUser user = conversation.getUser(Integer.parseInt(parameters.get(1)));
        conversation.addMessage(new Message(user, parameters.get(2)));
    }
    
}
